package com.ap.core.validation.message.rules;

import com.ap.core.common.types.RefundReasonType;
import com.ap.core.message.managerefund.info.RequestRetrieveRefundAccountInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.OriginalInfo;

/**
 * User: Gibu.Paul The Merchant must have an active status when refundReasonType
 * is Merchant Initiated
 */

public class RV0022Rule
		extends AbstractMerchantCheckRule<RequestRetrieveRefundAccountInfo, OriginalInfo>{

	@Override
	public boolean validate(
		MessageValidationInfo<RequestRetrieveRefundAccountInfo, OriginalInfo> infoObject) {
		boolean pass = true;
		String refundReasonTypeStr =  infoObject.getBoundObject().getRefundRequestInfo().getRefundReasonType();
		RefundReasonType refundReasonType = RefundReasonType.getValueOf(refundReasonTypeStr);
		if (refundReasonType != null && refundReasonType.isMerchantInitiated()) {
			pass = isMerchantActive(infoObject.getBoundObject().getRefundRequestInfo().getMerchantId());
		}
		return pass;
	}
}